package com.twu.biblioteca;

import org.springframework.stereotype.Component;

import javax.inject.Inject;
import java.util.Map;

@Component
public class Printer {

    private ConsoleOutput output;

    @Inject
    public Printer(ConsoleOutput consoleOutput) {
        this.output = consoleOutput;
    }

    public void printBooks(Map<String,Book> books) {
        for (Book book : books.values())
            output.write(book.getTitle());
        if (books.isEmpty())
            output.write("Biblioteca book collection is empty");
    }

    public void printMovieCatalog(Map<String,Movie> movies) {
        if (movies.isEmpty()) {
            output.write("Biblioteca movie collection is empty");
        } else {
            output.write("Movie - Year - Director - Rating");
            for (Movie m : movies.values())
                output.write(m.getTitle() + " " + m.getYear() + " " + m.getDirector() + " " + m.getRating().toString());
        }
    }

    public void printMenuOptions() {
        output.write("Choose your option (pressing the correspondent number between brackets and enter):");
        output.write("[1] Login");
        output.write("[2] Check Biblioteca book list");
        output.write("[3] Reserve a book");
        output.write("[4] Check your membership details");
        output.write("[5] List movie catalog");
        output.write("[6] Logout");
        output.write("[7] Exit");
    }

    public void printWelcomeMessage() {
        output.write("Welcome to Biblioteca");
    }

    public void printInvalidOption() {
        output.write("Select a valid option!!");
    }

    public void printExitMessage() {
        output.write("See you later!");
    }

    public void printMembershipDetails() {
        output.write("Please talk to a Librarian. Thank you.");
    }

    public void printMembershipDetails(User user) {
        output.write("Name: " + user.getName());
        output.write("Email: " + user.getEmail());
        output.write("Phone: " + user.getPhone());
    }

    public void printWhatIsTheBookTitle() {
        output.write("Type the book title you want to reserve:");
    }

    public void printBookReservedSuccessfully() {
        output.write("Thank You! Enjoy the book.");
    }

    public void printBookIsNotAvailable() {
        output.write("Sorry we don't have that book yet.");
    }

    public void printTypeUsername() {
        output.write("Type username:");
    }

    public void printTypePassword() {
        output.write("Type password");
    }

    public void printLoginSuccessful() {
        output.write("Successfull login.");
    }

    public void printInvalidLogin() {
        output.write("Invalid login.");
    }

    public void printNeedsToBeLoggedForThisOperation() {
        output.write("Needs to be logged for this operation.");
    }
}
